<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.common.css"/>
		<style type="text/css">
		 body{ overflow: visible;}
			.hy-upload-header{ overflow: hidden; min-height: 20px;padding: 19px;margin-bottom: 20px;background-color: #f5f5f5;border: 1px solid #e3e3e3;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.05);box-shadow: inset 0 1px 1px rgba(0,0,0,0.05);}
		    .ke-button-common{ display: none;}
		    select,.hy-upload-main input{ width: 100%; font-size: 14px;}
		    ul{ list-style-type: none;}
		    .hy-upload-main label{ border: 2px solid #ddd; width: 100%;background: #ddd;height: 30px;cursor: pointer;border-radius: 4px;line-height: 30px;padding-left: 10px;}
		    .am-icon-spinner{ font-size: 16px;}
		    .hy-upload-loading{ text-align: center;display: none;}
		</style>
	     
	</head>
	<body>
	<div class="am-g">
		<div class="hy-upload-header">
			<div class="am-u-md-7">
			 <select id="hy-upload-path"  name="path">
				{foreach from=$dir item=d}
				<option {if $_GET['s']==$d}selected="selected"{/if} value="{$d}">{$d}</option>
				{/foreach}
			</select>	
			</div>
			<div class="am-u-md-5">
				<input id="hy-uploadimg"  type="button" value="submit" />
			</div>
			
		</div>
		<div class="hy-upload-loading">
			<i class="am-icon-spinner am-icon-spin"></i>
		</div>
		<div class="hy-upload-main">
			<ul>
			</ul>
			<p>点击列表项可取消选择</p>
		</div>
		<div class="hy-upload-footer">
			<button class="am-btn am-btn-primary am-btn-block hy-js-save">确定并返回</button>
		</div>
	</div>
	<script src="{$_C.hy_path}js/hy.base.js"></script>
	<script src="{$_C.hy_path}js/jquery-1.7.2.min.js"></script>
    <script src="{$_C.hy_path}js/amazeui.min.js"></script>	
    <script type="text/javascript" src="{$_C.hy_path}js/editor/kindeditor.js"></script>
    <script type="text/javascript">
    	KindEditor.ready(function(K) {
		$("input[id^='hy-uploadimg']").each(function(i, v) {
			var _this = this;
			var index = i;
			var upload_url='index.php?g=admin&m=index&a=act_upload'
			var _callback = function(data) {
				    $('.hy-upload-loading').hide();
					if (data.error === 0) {
						var url = K.formatUrl(data.url, 'absolute');
						K('.hy-upload-main ul').append('<li><label class="am-icon-photo" style="border:2px solid #0e90d2">'+url+'<input checked="checked" type="checkbox" class="hy-hide" name="uploadimg" id="" value="'+url+'" /></label></li>');
					} else {
						alert(data.message);
					}
				}
			var uploadbutton = K.uploadbutton({
					button: _this,
					fieldName: 'file_name',
					url: upload_url,
					afterUpload: _callback,
					afterError: function(str) {
						$('.hy-upload-loading').hide();
						alert('自定义错误信息: ' + str);
					}
				});
				uploadbutton.fileBox.change(function(e) {
					$('.hy-upload-loading').show();
					$('.ke-form').append('<input type="hidden" name="filepath" value='+$('#hy-upload-path').val()+'/>');
					uploadbutton.submit();
				});
			
		}); //each
	});
    </script>
    <script type="text/javascript">
  
    $(function(){
    	$('.hy-upload-main input').live('click',function(){
    		if(this.checked!=true)
    		{
    			$(this).parent().css('border','2px solid #ddd')
    		}
    		else
    		{
    			$(this).parent().css('border','2px solid #0e90d2')
    		}
    	});
    })
    	
   
    </script>
    <script src="{$_C.hy_path}js/admin.js" type="text/javascript" charset="utf-8"></script>
	</body>
	
</html>
